package com.joysuch.wwyt.bp.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.joysuch.wwyt.api.dataaccess.bean.OrientationV3AlarmBean;
import com.joysuch.wwyt.bp.entity.AlarmMessage;
import com.joysuch.wwyt.bp.entity.bean.AlarmMeaasgeSearchBean;
import com.joysuch.wwyt.bp.entity.bean.AlarmMessageBean;
import com.joysuch.wwyt.core.bean.SimpleListIntegerBean;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.exception.ApiBusinessException;
import com.joysuch.wwyt.monitoringcenter.bean.AlarmMessageCountBean;
import com.joysuch.wwyt.monitoringcenter.bean.McAlarmMessageBean;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * AI报警
 * </p>
 *
 * @author zr
 * @since 2021-12-09
 */
public interface AlarmMessageService extends IService<AlarmMessage> {

    /**
     * 保存或者修改报警信息
     *
     * @param alarmMessageBean
     */
    void saveOrUpdateAlarm(AlarmMessageBean alarmMessageBean) throws ApiBusinessException;

    /**
     * ai报警分页
     *
     * @param bean
     * @return
     */
    ResultBean alarmMessagePage(AlarmMeaasgeSearchBean bean);

    /**
     * ai报警数量
     *
     * @return
     */
    Integer aiAlarmMessageCount(Long tenentId, String orgCode,List<Integer> typeList);

    /**
     * 根据id获取ai报警信息
     *
     * @param id
     * @return
     */
    AlarmMessage getMessageById(Long id);

    void setAllMeaageHandled(String msg, String alarmReason, Long handleBy, Date now);

    List<McAlarmMessageBean> queryAIAlarmMessage(Integer state,Integer alarmType);

    List<SimpleListIntegerBean> aIAlarmSubType(Integer alarmType);

    Integer findCameraAlarm(String cameraName, Long tenentId, String orgCode);

    /**
     * 获取时间点到现在的报警信息
     *
     * @param startTime
     * @return
     */
    List<AlarmMessage> statsForCountInDay(LocalDateTime startTime, Long tenentId, String orgCode);

    /**
     * 将定位报警保存在本地
     *
     * @param type
     * @param alarmBean
     */
    void saveAlarm(String type, OrientationV3AlarmBean alarmBean);

    /**
     * 获取各类型报警总数
     *
     * @param tenentId
     * @param orgCode
     * @return
     */
    List<AlarmMessage> getAlarmTypesNumber(Long tenentId, String orgCode);


    Page<AlarmMessage> getAlarmMessagePageData(AlarmMeaasgeSearchBean searchBean);

    /**
     * 根据类型和状态获取报警
     *
     * @param alarmType
     * @param status
     * @param tenentId
     * @param orgCode
     * @return
     */
    List<AlarmMessage> findAllByAlarmTypeAndStatus(Integer alarmType, int status, Long tenentId, String orgCode);

    List<AlarmMessageCountBean> findCameraAlarms(List<String> names, Long currentTenantId, String currentOrgCode);
}
